<?php
class ModelCategoryStock extends Model 
{
	public function getList()
	{
		$query = $this->db->query("Select * from `stock`");
		return $query->rows;
	}
	
	public function getItem($stockid)
	{
		$query = $this->db->query("Select * from `stock` where stockid = '".$stockid."'");
		return $query->row;
	}
	
	public function insert($data)
	{
		$stockid=$this->db->escape(@$data['stockid']);
		$stockname=$this->db->escape(@$data['stockname']);
		$stockdescription=$this->db->escape(@$data['stockdescription']);
		
		$field=array(
						'stockname',
						'stockdescription'
					);
		$value=array(
						$stockname,
						$stockdescription
					);
		$this->db->insertData("stock",$field,$value);
	}
	
	public function update($data)
	{
		$stockid=$this->db->escape(@$data['stockid']);
		$stockname=$this->db->escape(@$data['stockname']);
		$stockdescription=$this->db->escape(@$data['stockdescription']);
		
		$field=array(
						'stockname',
						'stockdescription'
					);
		$value=array(
						$stockname,
						$stockdescription
					);
					
		$where="stockid = '".$stockid."'";
		$this->db->updateData("stock",$field,$value,$where);
	}	
			
	public function delete($stockid)
	{
		$stockid=$this->db->escape(@$stockid);
		$where="stockid = '".$stockid."'";
		$this->db->deleteData('stock',$where);
	}
	
	public function deletes($data)
	{
		foreach($data as $stockid)
		{
			$this->delete($stockid);
		}		
	}
	
}

?>